package com.feihong.activity.entity;

import lombok.Data;

@Data
public class JsonResult<T> {
    private String code;
    private T data;
    private String msg;
    private String errorMsg;

    public JsonResult(){
        this.code = "200";
        this.msg = "操作成功";
    }

    public JsonResult(String code ,String msg){
        this.code = code;
        this.msg = msg;
    }

    public JsonResult(T data){
        this.data = data;
        this.code = "200";
        this.msg = "操作成功";
    }

    public JsonResult(T data, String msg) {
        this.data = data;
        this.code = "200";
        this.msg = msg;
    }


    public static JsonResult success(String msg){
        JsonResult<Object> jsonResult = new JsonResult<>();
        jsonResult.setMsg(msg);
        jsonResult.setCode("200");
        return jsonResult;
    }

    public static JsonResult failure(String msg){
        JsonResult<Object> jsonResult = new JsonResult<>();
        jsonResult.setMsg(msg);
        jsonResult.setCode("500");
        return jsonResult;
    }
}
